package com.hs.device.charger.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hs.common.core.constant.CacheConstants;
import com.hs.common.redis.service.RedisService;
import com.hs.communication.common.entity.ChargerData;
import com.hs.device.charger.entity.vo.ChargerDataVo;
import com.hs.device.charger.mapper.ChargerDataMapper;
import com.hs.device.charger.service.ChargerDataService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ChargerDataServiceImpl extends ServiceImpl<ChargerDataMapper, ChargerData> implements ChargerDataService {

    @Resource
    private ChargerDataMapper chargerDataMapper;

    @Resource
    private RedisService redisService;

    @Override
    public int insert(ChargerData chargerData) {
        return chargerDataMapper.insert(chargerData);
    }

    @Override
    public ChargerData getData(String sn) {
        ChargerData latestChargerData = redisService.getCacheObject(CacheConstants.LATEST_CHARGER_DATA + sn);
        return latestChargerData;
    }
}
